<template>
    <h2>登录本系统</h2>
    <table>
        <tr>
            <td>用户名</td>
            <td>
                <input type="text" placeholder="请输入用户名" v-model="name"/>
            </td>
        </tr>
        <tr>
            <td>密码</td>
            <td>
                <input type="password" v-model="pwd"/>
            </td>
        </tr>
        <tr>
            <td></td>
            <td>
                <input type="button"  value="登录" class="btn btn-success" @click="Login"/>
            </td>
        </tr>
    </table>
</template>
<script setup lang="ts">
 import { ref } from 'vue';
 import axios from 'axios';
import { useStore } from '@/stores/Index';

const stores=useStore();
 const name=ref("");
 const pwd=ref();

 const Login=()=>{
    axios.get("https://localhost:7010/api/RoomNumType/Login",{
        params:{
            name:name.value,
            pwd:pwd.value
        }
    })
    .then(res=>{
        if(res.data>0){
            stores.Username=name.value;
            alert(stores.Username);
            alert("登录成功");
            
        }
        else{
            alert("登录失败");
        }
    })
 }

</script>